﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SimpleChart.Kernel;
using SimpleChart.Kernel.Series;
using System.Drawing;

namespace SimpleChart.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            Chart chart = new Chart();
            chart.Title = "Title Of Chart";
            chart.Data = GetTestData();
            chart.AxisXMember = "X";

            ColumnSeries columnSeries = new ColumnSeries() { Name = "ColumnSeries",
                AxisType = AxisYType.Left,
                AxisYMember = "Y1",
                Color = Color.Red};

            LineSeries lineSeries1 = new LineSeries() { Name = "LineSeries1",
                AxisType = AxisYType.Right,
                AxisYMember = "Y2",
                Color = Color.Purple,
                CirclePointColor = Color.Green,
                ShowCirclePoint = true,
                ShowValueLabel = true };

            LineSeries lineSeries2 = new LineSeries() { Name = "LineSeries2",
                AxisType = AxisYType.Right,
                AxisYMember = "Y3",
                Color = Color.Blue };

            chart.SeriesCollection.Add(columnSeries);
            chart.SeriesCollection.Add(lineSeries1);
            chart.SeriesCollection.Add(lineSeries2);

            Image image = chart.GetImage();
            image.Save("d:\\chart.jpg");
        }

        private static DataTable GetTestData()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("X");
            dt.Columns.Add("Y1");
            dt.Columns.Add("Y2");
            dt.Columns.Add("Y3");

            Random random = new Random();
            for (int i = 0; i < 8; i++)
            {
                DataRow row = dt.NewRow();
                row[0] = "X" + i;
                row[1] = float.Parse(random.Next(100000000, 1000000000).ToString()) * 1000;
                row[2] = random.Next(10) / 100000000f;
                row[3] = random.Next(10) / 100000000f;
                dt.Rows.Add(row);
            }

            return dt;
        }
    }
}
